package com.todo.common.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author zhangwenxiang
 * @date 2024/3/11 19:36
 * @description
 */
@Getter
@AllArgsConstructor
public enum CityTypeEnum {

    COUNTRY(0, "COUNTRY", "国家"),
    PROVINCE(1, "PROVINCE", "省"),
    CITY(2, "CITY", "市"),
    DISTRICT(3, "DISTRICT", "区"),
    ;

    private static Map<Integer, CityTypeEnum> typeMap = Arrays
            .stream(CityTypeEnum.values())
            .collect(Collectors.toMap(CityTypeEnum::getType, item -> item, (v1, v2) -> v2));

    private int type;
    private String code;
    private String name;


    public static CityTypeEnum getByType(Integer type) {
        return typeMap.get(type);
    }
}
